package com.leet.code;

import java.util.Arrays;

public class Code283 {
    public static void main(String[] args) {
        Code283 code = new Code283();
        int[] is = {0, 1, 0, 3, 12};
        code.moveZeroes(is);
        System.out.println(Arrays.toString(is));
    }


    public void moveZeroes(int[] nums) {
        if (nums == null || nums.length == 0) {
            return;
        }

        int i = 0;
        int j = 0;

        while (i < nums.length) {
            if (nums[i] == 0) {
                j++;
            } else {
                nums[i - j] = nums[i];
            }
            i++;
        }

        while (j > 0) {
            nums[nums.length - j] = 0;
            j--;
        }

    }

}
